import _CircularProgress from "@mui/material/CircularProgress";
import _useMediaQuery from "@mui/material/useMediaQuery";
import React from "react";
import BlockUi from "react-block-ui";
import ReactDom from "react-dom";
import { useSelector } from "react-redux";
import { jsx as _jsx } from "react/jsx-runtime";
var dom = null;
function Loading(props) {
    var _useSelector = useSelector(function(state) {
        return {
            loading: state.app.loading,
            theme: state.app.theme
        };
    }), loading = _useSelector.loading, theme = _useSelector.theme;
    var isPc = _useMediaQuery("(min-width:1280px)");
    return /*#__PURE__*/ _jsx(BlockUi, {
        style: {
            position: "relative",
            left: "0",
            right: "0",
            top: "0",
            bottom: "0",
            width: "100%",
            height: "100%"
        },
        className: "block_ui",
        blocking: loading,
        loader: /*#__PURE__*/ _jsx(_CircularProgress, {
            size: !isPc ? "8vw" : "38px",
            style: {
                position: "absolute",
                left: "50%",
                top: "50%",
                transform: "translate3d(-50%, -50%, 0)",
                color: theme == "dark" ? "#fff" : "var(--primary)"
            },
            color: "inherit"
        }),
        children: props.children
    });
}
Loading.show = function() {
    if (dom) return;
    dom = document.createElement("div");
    var wrap = document.body;
    /*#__PURE__*/ ReactDom.createPortal(/*#__PURE__*/ _jsx(BlockUi, {
        blocking: true,
        loader: /*#__PURE__*/ _jsx(_CircularProgress, {
            size: "8vw",
            style: {
                color: "var(--primary)"
            },
            color: "inherit"
        })
    }), wrap);
};
Loading.remove = function() {
    dom === null || dom === void 0 ? void 0 : dom.remove();
    dom = null;
};
export default Loading;

 //# sourceMappingURL=index.js.map